#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
		int a;
		int b;
		int c;
		int d;
		int e;
		int f;
		int g;
		int i;
} FancyStruct;

int main() {
	void * data;
	FancyStruct inst1;
	FancyStruct inst2;
	FancyStruct inst3;
	size_t size = sizeof(FancyStruct); // 32 for me

	inst1.i = 99;
	inst2.i = -900;
	inst3.i = 100500;
	
	data = malloc(size * 2);  // allocate space for two structs

	memcpy(data,&inst1,size); // okay, new structure is at *data.
	printf("%d\n",((FancyStruct*)data)->i); // 99
	
	memcpy(data+size,&inst2,size); // still okay, new structure at *(data+size)
	printf("%d\n",((FancyStruct*)(data+size))->i); // -900


	// alternativly

	void ** links = (void**)malloc(sizeof(void*)*2);

	links[0] = data;
	links[1] = data + size;
	

	memcpy(data+size*2,&inst3,size); // not okay, probably memory violition
	// we may be already segafaulted so who cares about last example?
	
	free(data); // even upon segfault we should try... at least.
	free(links);
	return 0;
}
